
<template>
    <div>
        <el-form :inline="true" :model="formInline" class="demo-form-inline" style="border-bottom:1px solid #ccc;">
           <!-- 法人名称-->
            <el-form-item :label="nowLangue.judName " class="selectMB10">
                <el-input size="mini" disabled v-if="legalPersonLists.length==1" v-model="formInline.legalPersonName" ></el-input>
                <el-select size="mini"  clearable v-model="formInline.legalPersonCode" v-else :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(legalPerson,index) in legalPersonLists" :key="index" :label="legalPerson.legalPersonCode" :value="legalPerson.legalPersonName">
                    </el-option>
                </el-select>
            </el-form-item>
           <!-- 检验商名称-->
            <el-form-item :label="nowLangue.surveyorName" class="selectMB10">
                <el-select size="mini" clearable v-model="formInline.productLineId" :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(product,index) in productLineList" :key="index" :label="product.label" :value="product.value"></el-option>
                </el-select>
            </el-form-item>
            <!--收货库房   -->
            <el-form-item :label="nowLangue.rceivingDepot" class="selectMB10">
                <el-select size="mini" clearable v-model="formInline.productLineId" :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(product,index) in productLineList" :key="index" :label="product.label" :value="product.value"></el-option>
                </el-select>
            </el-form-item>
            <!--收货库区-->
            <el-form-item :label="nowLangue.rceivingArea" class="selectMB10">
                <el-select size="mini" clearable v-model="formInline.status" :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(status,index) in statusList" :key="index" :label="status.label" :value="status.value"></el-option>
                </el-select>
            </el-form-item>
            <!-- 收货单号-->
            <el-form-item :label="nowLangue.rceivingCode" class="selectMB10">
                <el-input size="mini" v-model="formInline.materialName" :placeholder="nowLangue.pleaseImport+nowLangue.rceivingCode"></el-input>
            </el-form-item>
            <div class="dayChose">
                <!--收货时间-->
                <el-form-item :label="nowLangue.receiveDate" class="selectMB10" >
                    <el-date-picker type="date" :editable="false" v-model="formInline.startCreateTime" clearable :placeholder="nowLangue.pleaseSelect" @change="selectedCreateTimeBegin"></el-date-picker>
                </el-form-item>
                <span v-text="nowLangue.to"></span>
                <el-form-item  class="selectMB10">
                    <el-date-picker clearable :editable="false" v-model="formInline.endCreateTime"  type="date" :placeholder="nowLangue.pleaseSelect" @change="selectedCreateTimeEnd"></el-date-picker>
                </el-form-item>
            </div>
            <!-- 备件来源-->
            <el-form-item :label="nowLangue.spareSource" class="selectMB10">
                <el-select size="mini" clearable v-model="formInline.spareSource" :placeholder="nowLangue.pleaseSelect">
                    <el-option label="采购订单" :value="1"></el-option>
                    <el-option label="索赔订单" :value="2"></el-option>
                    <el-option label="维修订单" :value="3"></el-option>
                    <el-option label="备件返还" :value="4"></el-option>
                </el-select>
            </el-form-item>
            <!-- 备件编码-->
            <el-form-item :label="nowLangue.spareCode" class="selectMB10">
                <el-input size="mini" v-model="formInline.materialName" :placeholder="nowLangue.pleaseImport+nowLangue.spareCode"></el-input>
            </el-form-item>
            <!-- 备件粒度-->
            <el-form-item :label="nowLangue.spareGranularity" class="selectMB10">
                <el-select size="mini" clearable v-model="formInline.status" :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(status,index) in statusList" :key="index" :label="status.label" :value="status.value"></el-option>
                </el-select>
            </el-form-item>
            <!-- 是否加急-->
            <el-form-item :label="nowLangue.isUrgent" class="selectMB10">
                <el-select size="mini" clearable v-model="formInline.status" :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(status,index) in statusList" :key="index" :label="status.label" :value="status.value"></el-option>
                </el-select>
            </el-form-item>
            <!-- 备件名称-->
            <el-form-item :label="nowLangue.spareName" class="selectMB10" v-if="show">
                <el-input size="mini" v-model="formInline.materialName" :placeholder="nowLangue.pleaseImport+nowLangue.spareName"></el-input>
            </el-form-item>
            <!-- 备件小类-->
            <el-form-item :label="nowLangue.spareClass" class="selectMB10" v-if="show">
                <el-select size="mini" clearable v-model="formInline.status" :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(status,index) in statusList" :key="index" :label="status.label" :value="status.value"></el-option>
                </el-select>
            </el-form-item>
            <!-- 计划大类-->
            <el-form-item :label="nowLangue.planClass" class="selectMB10" v-if="show">
                <el-select size="mini" clearable v-model="formInline.status" :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(status,index) in statusList" :key="index" :label="status.label" :value="status.value"></el-option>
                </el-select>
            </el-form-item>
            <!-- 产品线-->
            <!--<el-form-item :label="nowLangue.productLine" class="selectMB10" v-if="show">
                <el-select size="mini" clearable v-model="formInline.status" :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(status,index) in statusList" :key="index" :label="status.label" :value="status.value"></el-option>
                </el-select>
            </el-form-item>-->
            <!-- 供应商名称-->
            <el-form-item :label="nowLangue.supplierName" class="selectMB10" v-if="show">
                <el-input size="mini" v-model="formInline.materialName" :placeholder="nowLangue.pleaseImport+nowLangue.spareName"></el-input>
            </el-form-item>
            <!-- ASN编号-->
            <el-form-item :label="nowLangue.asnCode" class="selectMB10" v-if="show">
                <el-input size="mini" v-model="formInline.materialName" :placeholder="nowLangue.pleaseImport+nowLangue.asnCode"></el-input>
            </el-form-item>
            <!-- PO编号-->
            <el-form-item :label="nowLangue.poCode" class="selectMB10" v-if="show">
                <el-input size="mini" v-model="formInline.materialName" :placeholder="nowLangue.pleaseImport+nowLangue.poCode"></el-input>
            </el-form-item>
            <!-- 在库时长-->
            <el-form-item :label="nowLangue.inStoreHour" class="selectMB10" v-if="show">
                <el-input size="mini" v-model="formInline.materialName" :placeholder="nowLangue.pleaseImport+nowLangue.inStoreHour"></el-input>
            </el-form-item>
            <el-form-item class="selectMB10">
                <el-button class="bolder outsideBtnBS selectAll"  size="mini" type="danger"  @click="show=!show" v-if="!show" v-text="nowLangue.more"></el-button>
                <el-button class="bolder outsideBtnBS selectAll"  size="mini" type="danger"  @click="show=!show" v-if="show" v-text="nowLangue.packUp"></el-button>
                <el-button class="bolder outsideBtnBS selectAll" :disabled="selectDisabled" size="mini" type="danger" @click="queryClick()" v-text="nowLangue.query"></el-button>
            </el-form-item>
        </el-form>
        <!--表格-->
        <label class="default-label" v-text="nowLangue.listOfNewSpareParts"></label>
        <!--新增按钮-->
        <el-button class="bolder outsideBtnBS" v-if="formInline.spareSource==4" size="mini" type="danger" v-text="nowLangue.AddRMC" @click="addRMC"><!--新增RMC--></el-button>
        <el-button class="bolder outsideBtnBS" v-else size="mini" type="danger" v-text="nowLangue.AddIQC" @click="addIQC"><!--新增IQC--></el-button>
        <el-button class="bolder outsideBtnBS" size="mini" type="danger" v-text="nowLangue.urgentSign"><!--加急标记--></el-button>
        <el-button class="bolder outsideBtnBS" size="mini" type="danger" v-text="nowLangue.leadOut"><!--导出--></el-button>
        <el-table :data="quliTestData" border style="width: 100%;" v-loading.body="loading" :element-loading-text="nowLangue.loadDesperately" @selection-change="handleSelectedEngReplace">
            <el-table-column type="index" header-align="center" align="center" :label="nowLangue.sequence" width="40"></el-table-column>
            <!--操作-->
            <el-table-column type="selection" align="center" width="40"></el-table-column>
            <!--加急-->
            <el-table-column prop="" :label="nowLangue.urgent" header-align="center" show-overflow-tooltip></el-table-column>
            <!--备件编码-->
            <el-table-column prop="" :label="nowLangue.spareCode" header-align="center" show-overflow-tooltip></el-table-column>
            <!--备件名称-->
            <el-table-column prop="" :label="nowLangue.spareName" header-align="center"  show-overflow-tooltip></el-table-column>
            <!--收货数量-->
            <el-table-column prop="" :label="nowLangue.receiveCount" header-align="center" show-overflow-tooltip></el-table-column>
            <!--未借出数量-->
            <el-table-column prop="" :label="nowLangue.notLendCount" header-align="center" show-overflow-tooltip></el-table-column>
            <!--已借出数量-->
            <el-table-column prop="" :label="nowLangue.lendCount" header-align="center" show-overflow-tooltip></el-table-column>
            <!--备件标识-->
            <el-table-column prop="" :label="nowLangue.spareIdentify" header-align="center" show-overflow-tooltip></el-table-column>
            <!--收货时间-->
            <el-table-column prop="" :label="nowLangue.receiveTime" header-align="center" show-overflow-tooltip></el-table-column>
            <!--在库时长（小时）-->
            <el-table-column prop="" :label="nowLangue.inStoreHours" header-align="center" show-overflow-tooltip></el-table-column>
            <!--备件小类-->
            <el-table-column prop="" :label="nowLangue.spareClass" header-align="center" show-overflow-tooltip></el-table-column>
            <!--计划大类-->
            <el-table-column prop="" :label="nowLangue.planClass" header-align="center" show-overflow-tooltip></el-table-column>
            <!--产品线-->
            <el-table-column prop="" :label="nowLangue.productLine" header-align="center" show-overflow-tooltip></el-table-column>
            <!--收货人-->
            <el-table-column prop="" :label="nowLangue.receiveMan" header-align="center" show-overflow-tooltip></el-table-column>
            <!--收货单号-->
            <el-table-column prop="" :label="nowLangue.receiveCode" header-align="center" show-overflow-tooltip></el-table-column>
        </el-table>
    </div>
</template>
<script>
    export default {
        data() {
            return {
                nowLangue:{},
                languageScoped:{
                    zh:{
                        "pleaseSelect":"请选择",
                        "pleaseImport":"请输入",
                        "judName":"法人信息",
                        "spareCode":"备件编码",
                        "spareName":"备件名称",
                        "createDate":"创建日期",
                        "to":"至",
                        "query":"查询",
                        "more":"更多",
                        "packUp":"收起",
                        "loadDesperately":"拼命加载中",
                        "sequence":"序",
                        "operate":"操作",
                        "listOfNewSpareParts":"待质检借用明细",
                        "surveyorName":"检验商名称",
                        "rceivingDepot":"收货库房",
                        "rceivingArea":"收货库区",
                        "rceivingCode":"收货单号",
                        "receiveDate":"收货时间",
                        "spareSource":"备件来源",
                        "spareGranularity":"备件粒度",
                        "isUrgent":"是否加急",
                        "AddIQC":"新增IQC",
                        "AddRMC":"新增RMC",
                        "urgentSign":"加急标记",
                        "leadOut":"导出",
                        "urgent":"加急",
                        "receiveCount":"收货数量",
                        "notLendCount":"未借出数量",
                        "lendCount":"已借出数量",
                        "spareIdentify":"备件标识",
                        "receiveTime":"收货时间",
                        "inStoreHours":"在库时长(小时)",
                        "spareClass":"备件小类",
                        "planClass":"计划大类",
                        "productLine":"产品线",
                        "receiveMan":"收货人",
                        "receiveCode":"收货单号",
                        "supplierName":"供应商名称",
                        "asnCode":"ASN编号",
                        "poCode":"PO编号",
                        "inStoreHour":"在库时长"
                    },
                    en:{
                        "pleaseSelect":"please select",
                        "pleaseImport":"please import ",
                        "judName":"jud Name",
                        "spareCode":"spare Code",
                        "spareName":"spare Name",
                        "createDate":"create Date",
                        "to":"to",
                        "query":"query",
                        "more":"more",
                        "packUp":"packUp",
                        "loadDesperately":"load Desperately",
                        "sequence":"sequence",
                        "listOfNewSpareParts":"list of new spare parts",
                        "surveyorName":"surveyorName",
                        "rceivingDepot":"rceivingDepot",
                        "rceivingArea":"rceivingArea",
                        "rceivingCode":"rceivingCode",
                        "receiveDate":"receiveDate",
                        "spareSource":"spareSource",
                        "spareGranularity":"spareGranularity",
                        "isUrgent":"isUrgent",
                        "AddIQC":"AddIQC",
                        "AddRMC":"AddRMC",
                        "urgent":"urgent",
                        "urgentSign":"urgentSign",
                        "leadOut":"leadOut",
                        "receiveCount":"receiveCount",
                        "notLendCount":"notLendCount",
                        "lendCount":"lendCount",
                        "spareIdentify":"spareIdentify",
                        "receiveTime":"receiveTime",
                        "inStoreHours":"inStoreHours(Hours)",
                        "spareClass":"spareClass",
                        "planClass":"planClass",
                        "productLine":"productLine",
                        "receiveMan":"receiveMan",
                        "receiveCode":"receiveCode",
                        "supplierName":"supplierName",
                        "asnCode":"asnCode",
                        "poCode":"poCode",
                        "inStoreHour":"inStoreHour"
                    }
                },
                // 查询表单
                formInline:{
                    legalPersonId:'',
                    legalPersonCode:"",
                    legalPersonName:'',
                    spareSource:"采购订单",
                },
                legalPersonLists:[],//法人名称列表
                legalPersonDropDown:[], //法人名称
                quliTestData:[],//待质检借用明细
                //查询禁用
                selectDisabled:false,

                show:false,//更多
                loading:false,
            };
        },
        created:function(){
            this.languageType=="zh"?this.nowLangue=this.languageScoped.zh:this.nowLangue=this.languageScoped.en;
        },
        computed:{
            languageType(){
                return this.$store.state.languageType;
            }
        },
        watch:{
            languageType(){
                this.languageType=="zh"?this.nowLangue=this.languageScoped.zh:this.nowLangue=this.languageScoped.en;
            }
        },
        //进入页面立即运行此方法
        mounted: function () {
            var _this = this;
            _this.$store.commit('currentActive', 'TestLend');
            //ajax前后查询按钮禁用
            $(".selectAll").ajaxStart(function(){
                _this.selectDisabled=true;
            });
            $(".selectAll").ajaxStop(function(){
                _this.selectDisabled=false;
            });
        },
        methods:{
            // 选择创建开始日期
            selectedCreateTimeBegin(val){

            },
            // 选择创建结束日期
            selectedCreateTimeEnd(val){

            },
            // 查询法人名称
            legalPersonDropDownValue(){  //法人名称下拉列表值
                var _this = this;
                $.ajax({
                    type:'GET',
                    url:_this.procurement_service+"legalPerson/ofCurrentUser",
                    cache:false,
                    success:function(data){
                        if(data.success){
                            _this.legalPersonLists = data.data;
                            if(_this.legalPersonLists.length == 1){
                                _this.formInline.legalPersonId =_this.legalPersonLists[0].id;
                                _this.formInline.legalPersonCode =_this.legalPersonLists[0].legalPersonCode;
                                _this.formInline.legalPersonName =_this.legalPersonLists[0].legalPersonName;
                            }
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            handleSelectedEngReplace(val){

            },
            //下拉框公共接口
           /* getCommonList(){
                var _this=this;
                var tmp=["substituteForm.productLine","substituteForm.status"];
                $.ajax({
                    type: 'POST',
                    url: _this.metadata_service+"metadata/getPullDownList",
                    cache: false,
                    data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType: "application/json;charset=utf-8",
                    success: function (data) {
                        if (data.success) {
                            _this.productLineList=data.data['substituteForm.productLine'];//产品线集合
                            _this.statusList=data.data['substituteForm.status'];//状态集合
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },*/
            //查询列表
            queryClick(){
                /*var _this=this;
                 _this.loading=true;
                 var urlAddress="";
                 if(this.isClickBySelect){
                     urlAddress="projectSubstitute/queryMaterialByPage";
                 }else{
                     urlAddress="projectSubstitute/queryIncreasementMaterialByPage";
                 }
                 var tmp={
                     productLineId:_this.formInline.productLineId,
                     legalPersonCode:_this.formInline.legalPersonCode,
                     startCreateTime:_this.formInline.startCreateTime,
                     endCreateTime:_this.formInline.endCreateTime,
                     materialCode:_this.formInline.materialCode,
                     materialName:_this.formInline.materialName,
                     status:_this.formInline.status,
                     pageIndex:_this.pageIndex,
                     pageSize:_this.pageSize
                 };
                 $.ajax({
                     type: 'POST',
                     url: _this.metadata_service+urlAddress,
                     cache: false,
                     data:JSON.stringify(tmp),
                     dataType:'JSON',
                     contentType: "application/json;charset=utf-8",
                     success: function (data) {
                         if (data.success) {
                             _this.loading=false;
                             _this.isPaging=true;
                             _this.totalPage=data.data.totalPage;
                             _this.totalNumber=data.data.totalNumber;
                             _this.productData=data.data.dataList;
                         }else{
                             _this.loading=false;
                            _this.common.errorTip(data.errorMessage)
                         }
                     }
                 });*/
            },
            //新增IQC
            addIQC(){
                this.$router.push({ path: 'IqcOutApply', query: { }});
            },
            addRMC(){
                this.$router.push({ path: 'RmcOutApply', query: { }});
            },
        }
    }
</script>



